package com.bsea.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.bsea.model.User;

@RestController
public class TestController {
	@RequestMapping("test1")
	public Map<String,String> test(){
		Map<String,String> m=new HashMap();
		m.put("rs", "hello angular");
		return m;
	}
	
	@RequestMapping("test2")
	public User test2(){
		User u=new User();
		u.setId(1l);
		u.setName("测试名字");
		u.setPwd("123");
		return u;
	}
	
	
	@RequestMapping("test3")
	public List<User> test3(){
		List<User> ls=new ArrayList();
		User u=new User();
		u.setId(1l);
		u.setName("测试名字");
		u.setPwd("123");
		User u1=new User();
		u1.setId(2l);
		u1.setName("测试名字2222");
		u1.setPwd("123456");
		ls.add(u);
		ls.add(u1);
		return ls;
	}
	
	@RequestMapping("test4")
	public Map<String,String>  test4(@RequestBody User user){
		System.out.println(user.getName());
		Map<String,String> m=new HashMap();
		m.put("rs", "N");
		m.put("reason", "用户名不存在");
		return m;
	}
	
	@RequestMapping("test5")
	public Map<String,String>  test5(@RequestBody List<User> ls){
		System.out.println("---test5---"+ls.get(0).getName());
		System.out.println("---test5---"+ls.get(1).getName());
		Map<String,String> m=new HashMap();
		m.put("rs", "N");
		m.put("reason", "用户名不存在");
		return m;
	}

}
